package utils;

import java.util.GregorianCalendar;
import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class Schedule implements ServletContextListener {

	/***************************************************************************
	 * Method name : schedule Return type : void 
	 * Decription :/tu dong xoa cac file bao cao tren server sau 5 phut(300 * 1000)
	 * Created date : Jun 14, 2008
	 * Author : Honglk
	 **************************************************************************/
	public void schedule() {
		Timer timer = new Timer();
		AutoProcess auto = new AutoProcess();
		timer.schedule(auto, GregorianCalendar.getInstance().getTime(),
				86400 * 1000);
	}
	public void scheduleDeletFile() {
		Timer timer = new Timer();
		AutoDelete auto = new AutoDelete();
		timer.schedule(auto, GregorianCalendar.getInstance().getTime(),
				3000 * 1000);
	}
	public Schedule() {
	}
	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("Server shutdown!");
		
	}

	public void contextInitialized(ServletContextEvent arg0) {
		System.out.println("Server starting!");
		this.schedule();
		this.scheduleDeletFile();
	}
}
